
   <script language="JavaScript">
   function konfirmasi(name)
   {
       tanya = confirm('Anda yakin ingin menghapus makalah '+ name + '?');
       if (tanya == true) return true;
       else return false;
   }
</script>

//<?php
//
//mysql_connect("localhost","root","");
//mysql_select_db("moduldok");
//
//$op = $_GET['op'];
//if ($op == "delete")
//{
//   $id = $_GET['id'];
//
//   $query = "DELETE FROM upload WHERE id = '$id'";
//   $hasil = mysql_query($query);
//}
//
//?>
   <?php

session_start();
$username = $_SESSION['username'];


// koneksi ke mysql
mysql_connect('localhost', 'root', '');
mysql_select_db('moduldok');

// membaca id file yang akan dihapus
$id = $_GET['id'];

// membaca username yang sedang login
$username = $_SESSION['username'];

// mencari username pemilik file yang akan dihapus
$query = "SELECT username FROM upload WHERE id = $id";
$hasil = mysql_query($query);


// mencocokkan username pemilik file dengan username yang sedang login
// jika cocok maka hapus file
$query = "DELETE FROM upload WHERE id = $id";

mysql_query($query);

echo "<h2>Anda login sebagai : " . $username . "</h2>";

// tampilkan menu user
echo "<p>[ <a href='FormTambahArtikel.php'>tambah artikel</a> ] [ <a href='FormHapusArtikel.php'>Hapus Artikel</a> ] [ <a href='lihatkontribusi.php'>lihat kontribusi</a> ] [ <a href='logout.php'>Logout</a> ] </p>";
echo "<h2>Daftar File Anda</h2>";
$query = "SELECT * FROM upload WHERE username = '$username'";


$query = "SELECT * FROM upload WHERE username = '$username'";
$hasil = mysql_query($query);
while ($data = mysql_fetch_array($hasil))
{
   

    echo "<li>" . $data['name'] . "</a> (<a href=\"".$_SERVER['PHP_SELF']."?op=delete&id=".$data['id']."\" onclick=\"return konfirmasi('".$data['name']."')\">Hapus</a>)</li>";

}

?>

